package com.its.common.redis.config;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;

/**
 * @Author xiaxp
 * @Date 2021-12-20 09:59
 * @Description
 */
@NoArgsConstructor
@AllArgsConstructor
@ConfigurationProperties(prefix = "its.redis")
public class RedissonProperties {
    private final String REDISSON_PATH = "classpath:redisson.json";
    private String config;
    private String file;
//
//    @Value("${spring.profiles.active}")
//    private String active;
//
//    public String getActiveEnv(){
//        String env = "";
//        if(!StringUtils.hasText(active)||"default".equals(active)){
//            env = "";
//        }else if(active.contains("dev")){
//            env = "dev";
//        }else if(active.contains("sit")){
//            env = "sit";
//        }else if(active.contains("prd")){
//            env = "prd";
//        }else if(active.contains("prod")){
//            env = "prod";
//        }else if(active.contains("uat")){
//            env = "uat";
//        }
//        return env;
//    }

    public String getJsonFile() {
        return jsonFile;
    }

    public void setJsonFile(String jsonFile) {
        this.jsonFile = jsonFile;
    }

    private String jsonFile = "classpath:redisson.json";


    public String getConfig() {
        return this.config;
    }

    public void setConfig(String config) {
        this.config = config;
    }

    public String getFile() {
        if(!StringUtils.hasText(file)){
            return REDISSON_PATH;
        }
        return this.file;
    }

    public void setFile(String file) {
        this.file = file;
    }
}
